<template>
  <div id="home">
    <headerTop @getContentShow="contentShow" @getSearchShow="SearchShow"></headerTop>
    <div class="content" v-show="contentShowFlag">
      <!-- 轮播图 -->
      <van-swipe :autoplay="3000" indicator-color="#e83632">
        <van-swipe-item v-for="(image, index) in images" :key="index">
          <img v-lazy="image" />
        </van-swipe-item>
      </van-swipe>
      <!-- 导航栏 -->
      <div class="nav">
        <ul>
          <li v-for="(item,i) in navImages" :key="i">
            <img :src="item.src" alt />
            <p>{{item.name}}</p>
          </li>
        </ul>
      </div>
      <!-- 最新公告 -->
      <div class="news-talk">
        <div class="talk-icon"></div>
        <div class="talk-icon-font"></div>
        <div class="text">
          <p>畅饮尝新季，低至满99减20</p>
          <p>初夏奶货据上火。有机奶粉馆两件8折</p>
        </div>
        <div class="more">
          <p>更多</p>
        </div>
      </div>
      <!-- 花样零食 -->
      <div class="good">
        <div class="top">
          <div class="left_good_item">
            <div class="inner">
              <div class="text">
                花样零食
                <div class="left-icon-flag"></div>
                <div class="right-icon-flag"></div>
              </div>
            </div>
          </div>
          <div class="right_good_item">
            <div class="inner">
              <div class="text">
                个人清洁
                <div class="left-icon-flag"></div>
                <div class="right-icon-flag"></div>
              </div>
            </div>
          </div>
        </div>
        <div class="content-list">
          <div v-for="(item,i) in goodsImages" :key="i">
            <img v-lazy="item" alt />
          </div>
        </div>
      </div>
      <!-- 广告长图 -->
      <div class="advert">
          <div v-for="(item,i) in advertImages" :key="i">
              <img v-lazy="item" alt="">
          </div>
      </div>
    </div>
    <!-- 搜索放一个组件 -->
    <div class="search" v-show="searchShowFlag">
        <search></search>
    </div>
  </div>
</template>
<script>
import headerTop from "../children/Header.vue";
import search from '../search/Search.vue';
export default {
  data() {
    return {
      images: [
        "../../images/banner.png",
        "../../images/banner.png",
        "../../images/banner.png",
        "../../images/banner.png",
        "../../images/banner.png"
      ],
      navImages: [
        { src: "../../images/home_footer_nav.png", name: "限时抢购" },
        { src: "../../images/home_nav_newstoday.png", name: "今日上新" },
        { src: "../../images/home_nav_goodRank.png", name: "好货排行" },
        { src: "../../images/home_nav_go.png", name: "出行必备" },
        { src: "../../images/home_nav_jiaju.png", name: "家具护理" },
        { src: "../../images/home_nav_eleshop.png", name: "五金家电" },
        { src: "../../images/home_nav_xihu.png", name: "清洁洗护" },
        { src: "../../images/home_nav_drink.png", name: "酒水饮料" }
      ],
      goodsImages: [
        "../../images/goods-1.png",
        "../../images/goods-2.png",
        "../../images/goods-3.png",
        "../../images/goods-4.png"
      ],
      advertImages:[
          "../../images/advert-1.png",
          "../../images/advert-2.png"
      ],
      contentShowFlag:true,
      searchShowFlag:false
    };
  },
  methods: {
    //传给子组件 子组件赋值给 这个组件  来显示隐藏content部分
    contentShow(flag){
        this.contentShowFlag = flag;
    },
    SearchShow(flag){
      this.searchShowFlag =flag;
    } 
  },
  components: {
    headerTop,
    search
  }
};
</script>
<style lang="less" scoped>
#home {
    margin-bottom: 1.2rem;
  .content {
    padding-top: 1.3rem;
  }
  .van-swipe {
    height: 2.45rem;
  }
  img {
    width: 100%;
  }
  /deep/.van-swipe__indicator {
    background-color: rgba(0, 0, 0, 0.5);
  }
  /deep/.van-grid-item__content {
    padding: 0;
  }
  .nav {
    background-color: #fff;
    padding-top: 0.25rem;
    ul {
      display: flex;
      width: 100%;
      flex-wrap: wrap;
      li {
        width: 25%;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        margin-bottom: 0.35rem;
        p {
          margin-bottom: 0;
          font-size: 0.28rem;
          color: #25282a;
          margin-top: 0.1rem;
        }
        img {
          width: 0.84rem;
          height: 0.85rem;
        }
      }
    }
  }
}
.news-talk {
  background-color: #fff;
  display: flex;
  flex-direction: row;
  .talk-icon {
    margin-left: 0.4rem;
    width: 0.5rem;
    height: 0.53rem;
    background: url("../../images/gonggao.png") no-repeat center center;
    background-size: 0.5rem 0.53rem;
  }
  .talk-icon-font {
    width: 0.6rem;
    height: 0.54rem;
    background: url("../../images/new_font.png") no-repeat center center;
    background-size: 0.6rem 0.54rem;
    margin-left: 0.1rem;
  }
  .text {
    margin-left: 0.25rem;
    width: 60%;
    p {
      font-family: "黑体";
      font-weight: 700;
      margin-bottom: 0;
      font-size: 0.24rem;
      height: 0.28rem;
      color: #212827;
      line-height: 0.28rem;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      margin-bottom: 0.035rem;
    }
  }
  .more {
    margin-left: 0.1rem;
    padding-top: 0.28rem;
    p {
      font-size: 0.24rem;
      padding-left: 0.25rem;
      height: 0.28rem;
      line-height: 0.28rem;
      color: #212827;
      border-left: 0.01rem solid #808080;
    }
  }
}
.good {
  margin-top: 0.2rem;
  background-color: #fff;
  .top {
    display: flex;
    flex-direction: row;
    .left_good_item,
    .right_good_item {
      width: 50%;
      display: flex;
      flex-direction: row;
      justify-content: center;
      padding-top: 0.3rem;
      .inner {
        width: 70%;
        height: 0.45rem;
        border-top: 0.01rem solid #005d83;
        border-left: 0.01rem solid #005d83;
        border-right: 0.01rem solid #005d83;
        position: relative;
        .text {
          width: 75%;
          padding: 0 0.1rem;
          height: 0.35rem;
          background-color: #fff;
          position: absolute;
          left: 50%;
          transform: translateX(-50%);
          top: -0.2rem;
          text-align: center;
          font-size: 0.35rem;
          color: #005d83;
          .left-icon-flag {
            width: 0.08rem;
            height: 0.08rem;
            background-color: #005d83;
            position: absolute;
            top: 0.16rem;
            left: 0.11rem;
            border-radius: 50%;
          }
          .right-icon-flag {
            width: 0.08rem;
            height: 0.08rem;
            background-color: #005d83;
            position: absolute;
            top: 0.16rem;
            right: 0.11rem;
            border-radius: 50%;
          }
        }
      }
    }
  }
  .content-list{
      padding-top: 0.15rem;
      display: flex;
      flex-direction: row;
      div{
          width: 25%;
          img{
              width: 100%;
          }
      }
  }
}
.advert{
    display: flex;
    flex-direction: row;
    div{
    width: 50%;
        img{
            width: 100%;
        }
    }
}
</style>